#!/bin/bash

TRANSDIR='transactions'
DVDFILE='empty.dvd'
MDVDFILE='empty.mdvd'
DAILY='./daily.sh'

declare -a DIRS

COUNTER=0

for i in $( ls -d $TRANSDIR/*/ | sed s/$TRANSDIR[/]// | sed s/[/]// ); do
    DIRS[$COUNTER]=$i
    ((COUNTER++))
done

COUNTER=0

for i in ${DIRS[@]}; do
    if [ $COUNTER -eq "0" ]
    then
        $DAILY $i
    else
        $DAILY $i current.dvd master.mdvd
    fi
    cp $TRANSDIR/master.mdvd $TRANSDIR/day$COUNTER.mdvd
    ((COUNTER++))
done